/**
 * Created by Administrator on 2018/1/18.
 */
layui.use(['jquery','form','layer'], function() {
    var $ = layui.jquery,
        layer = layui.layer,
        form = layui.form;

    $('#icon').change(function(){
        var icon = 'fa '+$(this).val();
        $('#show_icon').removeClass();
        $('#show_icon').addClass(icon);
    });

    //监听表单提交
    form.on('submit(menu_submit)', function(data){
        //ajax执行
        $.ajax({
            type: "post",
            url: '/admin/menu_edit',
            data:data.field,
            dataType: "json",
            success: function(data){
                if(data.code==200){
                    //关闭当前iframe页面
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                    parent.layer.msg('菜单修改成功',{icon:1});
                }else{
                    parent.layer.msg('菜单修改失败',{icon:2});
                }
            }
        });

        return false;
    });

});